<template>
  <footer class="footer">
    <!-- 在template中访问所有数据都不需要加this-->
    <span class="todo-count"
      >剩余<strong>{{ this.list.length }}</strong></span
    >
    <ul @click="changeSel" class="filters">
      <li>
        <!-- @click 绑定事件时,如果只执行一行代码, 可以直接写在后面,如果要用到data中的变量,不需要加 this,事件处理函数中不能加this -->
        <a
          @click="isSel = 'all'"
          :class="{ selected: isSel === 'all' }"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          @click="isSel = 'no'"
          :class="{ selected: isSel === 'no' }"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          @click="isSel = 'yes'"
          :class="{ selected: isSel === 'yes' }"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: ["list"],
  data() {
    return {
      isSel: "all",
    };
  },
  methods: {
    changeSel() {
      // 将 isSel 传递给父组件
      this.$emit("changeTask", this.isSel);
    },
  },
};
</script>